// 
// OV-chip 2.0 project
// 
// Digital Security (DS) group at Radboud Universiteit Nijmegen
// 
// Copyright (C) 2009
// 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License in file COPYING in this or one of the
// parent directories for more details.
// 
// Created 17.12.08 by Hendrik
// 
// netbeans generated code for the main window of the GUI
// 
// $Id: Ov_demo_gui.java,v 1.19 2010-02-18 14:02:09 tews Exp $

package ds.ov2.gui;

import ds.ov2.front.Applet_type;
import javax.swing.DefaultComboBoxModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;

/**
 * netbeans generated code for the main window of the graphical
 * demonstrator. This class contains only the code to create the main
 * window with all its components and the main method of the
 * demonstrator. The actions that are performed from the main window
 * are in {@link Gui_actions}.
 * <P>
 *
 * For a description of the command line arguments and the
 * non-standard accelerator keys see {@link Ov_demo}.
 *
 *
 * @author Hendrik Tews
 * @version $Revision: 1.19 $
 * @commitdate $Date: 2010-02-18 14:02:09 $ by $Author: tews $
 * @environment host
 * @CPP no cpp preprocessing needed
 */
public class Ov_demo_gui extends javax.swing.JFrame {

    /** serialVersionUID for Serializable interface */
    public static final long serialVersionUID = 1L;
    

    /**
     * 
     * Root class instance for the application logic.
     */
    private final Ov_demo ov_demo;

    /**
     * 
     * Actions instance.
     */
    private final Gui_actions gui_actions;

    /** Creates new form Ov_demo_gui */
    public Ov_demo_gui(String[] args) {
        ov_demo = new Ov_demo(args, this);
        gui_actions = ov_demo.gui_actions;
        initComponents();
    }

    /**
     * Wrapper of Applet_type for the applet-choice combo box.
     */
    public static class Applet_type_item {
        /** The applet type this item represents */
        public final Applet_type type;

        /**
         * Construct a new item.
         * @param type the type of the new item
         */
        public Applet_type_item(Applet_type type) {
            this.type = type;
        }

        /**
         *
         * @return string to be displayed in the combo box for this
         * applet type
         */
        @Override
        public String toString() {
            switch(type) {
                case PLAIN_RSA_APPLET:
                    return "Install plain coprocessor applet";
                case MONT_RSA_APPLET:
                    return "Install pure Montgomerizing applet";
                case SQUARED_RSA_APPLET:
                    return "Install plain square 2 applet";
                case SQUARED4_RSA_APPLET:
                    return "Install plain square 4 applet";
                default:
                    return type.toString();
            }
        }
    }

    /**
     * 
     * Model for the applet choice combo box. Contains the two OV-chip
     * applets. 
     */
    /*package*/ DefaultComboBoxModel applet_choice_combo_model =
        new DefaultComboBoxModel(
            new Applet_type_item[]{
                new Applet_type_item(Applet_type.SQUARED4_RSA_APPLET),
                new Applet_type_item(Applet_type.SQUARED_RSA_APPLET),
                new Applet_type_item(Applet_type.MONT_RSA_APPLET),
                new Applet_type_item(Applet_type.PLAIN_RSA_APPLET)
    });

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        tool_bar = new javax.swing.JToolBar();
        toolbar_exit_button = new javax.swing.JButton();
        toolbar_config_button = new javax.swing.JButton();
        toolbar_progress_button = new javax.swing.JButton();
        role_tabbed_pane = new javax.swing.JTabbedPane();
        ptls_office_tab = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        rsa_key_size_label = new javax.swing.JLabel();
        exp_size_label = new javax.swing.JLabel();
        SpinnerNumberModel key_spinner_model = new SpinnerNumberModel(32, 8, 2048, 32);
        key_size_spinner = new javax.swing.JSpinner(key_spinner_model);
        SpinnerNumberModel exp_spinner_model = new SpinnerNumberModel(8,8,512,1);
        exp_size_spinner = new javax.swing.JSpinner(exp_spinner_model);
        lenstra_exponent = new javax.swing.JCheckBox();
        attribute_label = new javax.swing.JLabel();
        SpinnerNumberModel attribute_spinner_model = new SpinnerNumberModel(4,1,5,1);
        attribute_number_spinner = new javax.swing.JSpinner(attribute_spinner_model);
        ptls_office_random_bases_box = new javax.swing.JCheckBox();
        ptls_params_load_button = new javax.swing.JButton();
        ptls_params_save_button = new javax.swing.JButton();
        ptls_params_new_button = new javax.swing.JButton();
        ptls_params_applet_combobox = new javax.swing.JComboBox();
        jPanel3 = new javax.swing.JPanel();
        ptls_office_install_all_button = new javax.swing.JButton();
        ptls_office_random_attributes_box = new javax.swing.JCheckBox();
        ptls_office_card_status_delete_button = new javax.swing.JButton();
        ptls_office_install_button = new javax.swing.JButton();
        ptls_office_personalize_button = new javax.swing.JButton();
        ptls_office_reset_button = new javax.swing.JButton();
        ptls_automaton_tab = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        ptls_run_button = new javax.swing.JButton();
        ptls_automaton_random_attributes_radio_button = new javax.swing.JRadioButton();
        ptls_automaton_constant_attributes_radio_button = new javax.swing.JRadioButton();
        entry_gate_tab = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        gate_run_automatically_check_box = new javax.swing.JCheckBox();
        entry_run_button = new javax.swing.JButton();
        status_line = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        card_log_text_pane = new javax.swing.JTextPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                formComponentShown(evt);
            }
        });

        tool_bar.setRollover(true);

        toolbar_exit_button.setText("Exit");
        toolbar_exit_button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolbar_exit_button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        toolbar_exit_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolbar_exit_buttonActionPerformed(evt);
            }
        });
        tool_bar.add(toolbar_exit_button);

        toolbar_config_button.setText("Configuration");
        toolbar_config_button.setFocusable(false);
        toolbar_config_button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolbar_config_button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        toolbar_config_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolbar_config_buttonActionPerformed(evt);
            }
        });
        tool_bar.add(toolbar_config_button);

        toolbar_progress_button.setText("Progress Log");
        toolbar_progress_button.setFocusable(false);
        toolbar_progress_button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolbar_progress_button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        toolbar_progress_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolbar_progress_buttonActionPerformed(evt);
            }
        });
        tool_bar.add(toolbar_progress_button);

        ptls_office_tab.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                ptls_office_tabComponentShown(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("System parameters"));

        rsa_key_size_label.setText("RSA key size:");
        rsa_key_size_label.setToolTipText("<html>Size of the RSA modulus,<BR>\nmust be between 512 and 1952 bits<BR>\nwith 32 bit increments.");

        exp_size_label.setText("Exponent size:");
        exp_size_label.setToolTipText("<html>Without compromizing security, the exponent<BR>\ncan be much smaller than the RSA modulus. The exponent<BR>\nmust not be larger than the RSA modulus.");

        key_size_spinner.setToolTipText(rsa_key_size_label.getToolTipText());
        key_size_spinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                key_size_spinnerStateChanged(evt);
            }
        });

        exp_size_spinner.setToolTipText(exp_size_label.getToolTipText());

        lenstra_exponent.setSelected(true);
        lenstra_exponent.setText("automatic exponent size");
        lenstra_exponent.setToolTipText("<html>Adjust exponent size automatically<BR>from the RSA key size according<BR>to Lenstra's estimations.");
        lenstra_exponent.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                lenstra_exponentItemStateChanged(evt);
            }
        });

        attribute_label.setText("Attributes");

        ptls_office_random_bases_box.setSelected(true);
        ptls_office_random_bases_box.setText("choose bases randomly");

        ptls_params_load_button.setText("Load from file");
        ptls_params_load_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ptls_params_load_buttonActionPerformed(evt);
            }
        });

        ptls_params_save_button.setText("Save to file");
        ptls_params_save_button.setEnabled(false);
        ptls_params_save_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ptls_params_save_buttonActionPerformed(evt);
            }
        });

        ptls_params_new_button.setText("Create new");
        ptls_params_new_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ptls_params_new_buttonActionPerformed(evt);
            }
        });

        ptls_params_applet_combobox.setModel(applet_choice_combo_model);
        ptls_params_applet_combobox.setToolTipText("Select the applet to be installed.");
        ptls_params_applet_combobox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                ptls_params_applet_comboboxItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ptls_params_applet_combobox, 0, 432, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(rsa_key_size_label)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(key_size_spinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(lenstra_exponent))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(exp_size_label)
                                .addComponent(attribute_label))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(attribute_number_spinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(ptls_office_random_bases_box))
                                .addComponent(exp_size_spinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(ptls_params_load_button)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(ptls_params_save_button)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(ptls_params_new_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {attribute_label, exp_size_label, rsa_key_size_label});

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {attribute_number_spinner, exp_size_spinner, key_size_spinner});

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {ptls_params_load_button, ptls_params_new_button, ptls_params_save_button});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ptls_params_applet_combobox, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rsa_key_size_label)
                    .addComponent(key_size_spinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lenstra_exponent))
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(exp_size_label)
                    .addComponent(exp_size_spinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(attribute_label)
                    .addComponent(attribute_number_spinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ptls_office_random_bases_box))
                .addGap(18, 18, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE, false)
                    .addComponent(ptls_params_load_button)
                    .addComponent(ptls_params_save_button)
                    .addComponent(ptls_params_new_button))
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Card Maintenance"));

        ptls_office_install_all_button.setText("(Re)Install applet & Personalize");
        ptls_office_install_all_button.setEnabled(false);
        ptls_office_install_all_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ptls_office_install_all_buttonActionPerformed(evt);
            }
        });

        ptls_office_random_attributes_box.setSelected(true);
        ptls_office_random_attributes_box.setText("choose attributes randomly");

        ptls_office_card_status_delete_button.setText("Status & Delete");
        ptls_office_card_status_delete_button.setEnabled(false);
        ptls_office_card_status_delete_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ptls_office_card_status_delete_buttonActionPerformed(evt);
            }
        });

        ptls_office_install_button.setText("Install Applet");
        ptls_office_install_button.setEnabled(false);
        ptls_office_install_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ptls_office_install_buttonActionPerformed(evt);
            }
        });

        ptls_office_personalize_button.setText("Personalize");
        ptls_office_personalize_button.setEnabled(false);
        ptls_office_personalize_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ptls_office_personalize_buttonActionPerformed(evt);
            }
        });

        ptls_office_reset_button.setText("Reset applet");
        ptls_office_reset_button.setEnabled(false);
        ptls_office_reset_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ptls_office_reset_buttonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(ptls_office_random_attributes_box)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(ptls_office_install_all_button)
                        .addGap(18, 18, 18)
                        .addComponent(ptls_office_reset_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(ptls_office_install_button)
                        .addGap(18, 18, 18)
                        .addComponent(ptls_office_personalize_button)
                        .addGap(18, 18, 18)
                        .addComponent(ptls_office_card_status_delete_button)))
                .addContainerGap(42, Short.MAX_VALUE))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {ptls_office_install_button, ptls_office_personalize_button});

        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ptls_office_random_attributes_box)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ptls_office_install_all_button)
                    .addComponent(ptls_office_reset_button))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ptls_office_install_button)
                    .addComponent(ptls_office_personalize_button)
                    .addComponent(ptls_office_card_status_delete_button))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout ptls_office_tabLayout = new javax.swing.GroupLayout(ptls_office_tab);
        ptls_office_tab.setLayout(ptls_office_tabLayout);
        ptls_office_tabLayout.setHorizontalGroup(
            ptls_office_tabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ptls_office_tabLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(ptls_office_tabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(6, 6, 6))
        );
        ptls_office_tabLayout.setVerticalGroup(
            ptls_office_tabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ptls_office_tabLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(87, 87, 87))
        );

        role_tabbed_pane.addTab("PTLS Office", ptls_office_tab);

        ptls_automaton_tab.setEnabled(false);
        ptls_automaton_tab.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                ptls_automaton_tabComponentShown(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Actions"));

        ptls_run_button.setText("obtain new signature");
        ptls_run_button.setEnabled(false);
        ptls_run_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ptls_run_buttonActionPerformed(evt);
            }
        });

        buttonGroup1.add(ptls_automaton_random_attributes_radio_button);
        ptls_automaton_random_attributes_radio_button.setSelected(true);
        ptls_automaton_random_attributes_radio_button.setText("perform random attribute updates");

        buttonGroup1.add(ptls_automaton_constant_attributes_radio_button);
        ptls_automaton_constant_attributes_radio_button.setText("leave attributes constant");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ptls_automaton_constant_attributes_radio_button)
                    .addComponent(ptls_automaton_random_attributes_radio_button)
                    .addComponent(ptls_run_button))
                .addContainerGap(199, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ptls_automaton_random_attributes_radio_button)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(ptls_automaton_constant_attributes_radio_button)
                .addGap(18, 18, 18)
                .addComponent(ptls_run_button)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout ptls_automaton_tabLayout = new javax.swing.GroupLayout(ptls_automaton_tab);
        ptls_automaton_tab.setLayout(ptls_automaton_tabLayout);
        ptls_automaton_tabLayout.setHorizontalGroup(
            ptls_automaton_tabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ptls_automaton_tabLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        ptls_automaton_tabLayout.setVerticalGroup(
            ptls_automaton_tabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ptls_automaton_tabLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(253, Short.MAX_VALUE))
        );

        role_tabbed_pane.addTab("PTLS Automaton", ptls_automaton_tab);

        entry_gate_tab.setEnabled(false);
        entry_gate_tab.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                entry_gate_tabComponentShown(evt);
            }
        });

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Actions"));

        gate_run_automatically_check_box.setSelected(true);
        gate_run_automatically_check_box.setText("automatically run entry protocol when card is inserted");
        gate_run_automatically_check_box.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gate_run_automatically_check_boxActionPerformed(evt);
            }
        });

        entry_run_button.setText("run entry protocol");
        entry_run_button.setEnabled(false);
        entry_run_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                entry_run_buttonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(gate_run_automatically_check_box)
                    .addComponent(entry_run_button))
                .addContainerGap(74, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(gate_run_automatically_check_box)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(entry_run_button)
                .addContainerGap(22, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout entry_gate_tabLayout = new javax.swing.GroupLayout(entry_gate_tab);
        entry_gate_tab.setLayout(entry_gate_tabLayout);
        entry_gate_tabLayout.setHorizontalGroup(
            entry_gate_tabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, entry_gate_tabLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        entry_gate_tabLayout.setVerticalGroup(
            entry_gate_tabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, entry_gate_tabLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(419, 419, 419))
        );

        role_tabbed_pane.addTab("Entry Gate", entry_gate_tab);

        status_line.setText("No system parameters configured.");

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Card Action Log"));

        card_log_text_pane.setEditable(false);
        jScrollPane1.setViewportView(card_log_text_pane);
        StyledDocument card_log_doc = (StyledDocument)card_log_text_pane.getDocument();
        StyleConstants.setBold(card_log_doc.addStyle("bold", null), true);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 455, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tool_bar, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(role_tabbed_pane, javax.swing.GroupLayout.DEFAULT_SIZE, 489, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(status_line, javax.swing.GroupLayout.DEFAULT_SIZE, 489, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(tool_bar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(role_tabbed_pane, javax.swing.GroupLayout.PREFERRED_SIZE, 429, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(status_line)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void toolbar_config_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toolbar_config_buttonActionPerformed
        gui_actions.toolbar_config_button(this);
    }//GEN-LAST:event_toolbar_config_buttonActionPerformed

    private void ptls_office_tabComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_ptls_office_tabComponentShown
            gui_actions.select_office(this);
    }//GEN-LAST:event_ptls_office_tabComponentShown

    private void entry_gate_tabComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_entry_gate_tabComponentShown
        gui_actions.select_entry_gate(this);
    }//GEN-LAST:event_entry_gate_tabComponentShown

    private void ptls_automaton_tabComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_ptls_automaton_tabComponentShown
        gui_actions.select_automaton(this);
    }//GEN-LAST:event_ptls_automaton_tabComponentShown

    private void ptls_office_install_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ptls_office_install_buttonActionPerformed
        gui_actions.ptls_office_install_applet(this);
}//GEN-LAST:event_ptls_office_install_buttonActionPerformed

    private void toolbar_exit_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toolbar_exit_buttonActionPerformed
        System.exit(0);
}//GEN-LAST:event_toolbar_exit_buttonActionPerformed

    private void key_size_spinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_key_size_spinnerStateChanged
        gui_actions.rsa_key_size_change(this);
    }//GEN-LAST:event_key_size_spinnerStateChanged

    private void lenstra_exponentItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_lenstra_exponentItemStateChanged
        gui_actions.lenstra_exponent_box_changed(evt, this);
    }//GEN-LAST:event_lenstra_exponentItemStateChanged

    private void ptls_params_load_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ptls_params_load_buttonActionPerformed
        gui_actions.ptls_params_load(this);
    }//GEN-LAST:event_ptls_params_load_buttonActionPerformed

    private void ptls_params_save_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ptls_params_save_buttonActionPerformed
        gui_actions.ptls_params_save(this);
    }//GEN-LAST:event_ptls_params_save_buttonActionPerformed

    private void ptls_params_new_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ptls_params_new_buttonActionPerformed
        gui_actions.ptls_params_new(this);
    }//GEN-LAST:event_ptls_params_new_buttonActionPerformed

    private void ptls_office_install_all_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ptls_office_install_all_buttonActionPerformed
        gui_actions.ptls_office_install_all(this);
}//GEN-LAST:event_ptls_office_install_all_buttonActionPerformed

    private void ptls_office_card_status_delete_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ptls_office_card_status_delete_buttonActionPerformed
        gui_actions.ptls_office_card_status(this);
}//GEN-LAST:event_ptls_office_card_status_delete_buttonActionPerformed

    private void ptls_office_personalize_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ptls_office_personalize_buttonActionPerformed
        gui_actions.ptls_office_personalize(this);
    }//GEN-LAST:event_ptls_office_personalize_buttonActionPerformed

    private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
        gui_actions.start_action(this);
    }//GEN-LAST:event_formComponentShown

    private void ptls_run_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ptls_run_buttonActionPerformed
        gui_actions.ptls_automaton_resign_button(this);
    }//GEN-LAST:event_ptls_run_buttonActionPerformed

    private void entry_run_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_entry_run_buttonActionPerformed
        gui_actions.entry_run_button(this);
    }//GEN-LAST:event_entry_run_buttonActionPerformed

    private void gate_run_automatically_check_boxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gate_run_automatically_check_boxActionPerformed
        gui_actions.entry_automatic_changed(this);
    }//GEN-LAST:event_gate_run_automatically_check_boxActionPerformed

    private void ptls_params_applet_comboboxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_ptls_params_applet_comboboxItemStateChanged
        gui_actions.applet_selection_changed(evt, this);
}//GEN-LAST:event_ptls_params_applet_comboboxItemStateChanged

    private void toolbar_progress_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toolbar_progress_buttonActionPerformed
        gui_actions.toolbar_progress_button();
    }//GEN-LAST:event_toolbar_progress_buttonActionPerformed

    private void ptls_office_reset_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ptls_office_reset_buttonActionPerformed
        gui_actions.ptls_office_reset_applet(this);
    }//GEN-LAST:event_ptls_office_reset_buttonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(final String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Ov_demo_gui(args).setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel attribute_label;
    javax.swing.JSpinner attribute_number_spinner;
    private javax.swing.ButtonGroup buttonGroup1;
    javax.swing.JTextPane card_log_text_pane;
    private javax.swing.JPanel entry_gate_tab;
    javax.swing.JButton entry_run_button;
    private javax.swing.JLabel exp_size_label;
    javax.swing.JSpinner exp_size_spinner;
    javax.swing.JCheckBox gate_run_automatically_check_box;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    javax.swing.JSpinner key_size_spinner;
    javax.swing.JCheckBox lenstra_exponent;
    javax.swing.JRadioButton ptls_automaton_constant_attributes_radio_button;
    javax.swing.JRadioButton ptls_automaton_random_attributes_radio_button;
    private javax.swing.JPanel ptls_automaton_tab;
    javax.swing.JButton ptls_office_card_status_delete_button;
    javax.swing.JButton ptls_office_install_all_button;
    javax.swing.JButton ptls_office_install_button;
    javax.swing.JButton ptls_office_personalize_button;
    private javax.swing.JCheckBox ptls_office_random_attributes_box;
    javax.swing.JCheckBox ptls_office_random_bases_box;
    javax.swing.JButton ptls_office_reset_button;
    javax.swing.JPanel ptls_office_tab;
    public javax.swing.JComboBox ptls_params_applet_combobox;
    private javax.swing.JButton ptls_params_load_button;
    private javax.swing.JButton ptls_params_new_button;
    javax.swing.JButton ptls_params_save_button;
    javax.swing.JButton ptls_run_button;
    javax.swing.JTabbedPane role_tabbed_pane;
    private javax.swing.JLabel rsa_key_size_label;
    javax.swing.JLabel status_line;
    javax.swing.JToolBar tool_bar;
    private javax.swing.JButton toolbar_config_button;
    private javax.swing.JButton toolbar_exit_button;
    private javax.swing.JButton toolbar_progress_button;
    // End of variables declaration//GEN-END:variables

}
